/**
 * @file axios数据请求插件
 * @author: vscode
 * @Date: 2018-06-05 22:12:29
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2018-12-06 11:21:49
 */

const axios = require('axios');
const config = require('../config');

// 创建axios实例
const instance = axios.create({
    baseURL: config.baseURL,
    timeout: 15000,
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    withCredentials: false
});

// request过滤器
instance.interceptors.request.use(
    config => {
        return config;
    },
    err => {
        return Promise.reject(err);
    }
);

// response过滤器
instance.interceptors.response.use(
    response => {
        return response;
    },
    err => {
        return Promise.reject(err);
    }
);

// 返回axios实例
module.exports = instance;
